package com.yanqu.road.dataHelper.action;

import com.yanqu.road.dataHelper.action.excel.Touhu2;
import com.yanqu.road.dataHelper.gameServer.GameServer;
import com.yanqu.road.dataHelper.manager.DataMgr;
import com.yanqu.road.dataHelper.manager.ServerMgr;
import com.yanqu.road.entity.servercenter.ServerInfo;
import com.yanqu.road.utils.string.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class Touhu2Excel extends actionBase{
    public void go(List<Long> serverList){
        ExecutorService executorService = Executors.newFixedThreadPool(1);
        List<Future> futureList = new ArrayList<>();
        /*for(Long serverId : serverList){
            if(ServerMgr.getServerInfoList().containsKey(serverId)){
                ServerInfo serverInfo = ServerMgr.getServerInfoList().get(serverId);
                Future future = executorService.submit(new Callable<Boolean>() {
                    @Override
                    public Boolean call() throws Exception {
                        GameServer testGameServer = new GameServer(serverInfo);
                        Log log = new Log(testGameServer);
                        log.go1();
                        return true;
                    }
                });
                futureList.add(future);
            }
        }
        isResult(futureList);
        DataMgr.makeExcelData2Txt("");
        DataMgr.outText("10月21日-11月14商店购买");*/

        String activityIdStr = "9013369,9013370,9013361,9013362,9013363,9013364,9013365,9013366,9013367,9013368,9013280,9013281,9013282,9013283,9013284,9013285,9013286";
        List<Integer> activityIdList = StringUtils.stringToIntegerList(activityIdStr,",");
        for(int activityId : activityIdList){
            futureList = new ArrayList<>();
            for(Long serverId : serverList){
                if(ServerMgr.getServerInfoList().containsKey(serverId)){
                    ServerInfo serverInfo = ServerMgr.getServerInfoList().get(serverId);
                    Future future = executorService.submit(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            GameServer testGameServer = new GameServer(serverInfo);
                            Touhu2 touhu = new Touhu2(testGameServer);
                            touhu.goAllActivity(activityId);
                            return true;
                        }
                    });
                    futureList.add(future);
                }
            }
            isResult(futureList);
            DataMgr.makeExcelData2Txt("");
            DataMgr.outText("投壶-"+activityId);
            System.err.println("``````============================================"+activityId+"完成");
        }
    }
}
